﻿#ifndef _OI_PLSCANNERCORE_PRODUCTSTATUS_HPP_
#define _OI_PLSCANNERCORE_PRODUCTSTATUS_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi { namespace PLScannerCore {

class OI_PLSCANNER_CORE_API ProductStatus
{
public:
    bool enable;

public:
    ProductStatus()
    {
        enable = false;
    }

    ProductStatus(const ProductStatus& p)
    {
        *this = p;
    }

    ProductStatus& operator=(const ProductStatus& p)
    {
        enable = p.enable;
        return *this;
    }

public:
    static bool loadFromSys(ProductStatus& status, const QString name);
};

class OI_PLSCANNER_CORE_API StatusReader
{
public:
    virtual ~StatusReader() {}

public:
    virtual bool ready() = 0;

public:
    virtual bool status(ProductStatus&) = 0;

public:
    static QSharedPointer<StatusReader> create(QString name);
};

class OI_PLSCANNER_CORE_API StatusReaderSystem
{
public:
    StatusReaderSystem();
    ~StatusReaderSystem();

public:
    QSharedPointer<StatusReader> reader(QString name);

public:
    void clear();

public:
    void addReader(QString name, QSharedPointer<StatusReader>);

public:
    static StatusReaderSystem* instance();

private:
    OI_DISABLE_COPY(StatusReaderSystem);
    OI_DECLARE_IMPL(StatusReaderSystem);
};

} }

#endif
